<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/5/21
 * Time: 19:09
 */

namespace iBrand\Shop\Core\Models;


use Illuminate\Database\Eloquent\Model;

class RefundPayment extends Model
{
    protected $guarded = ['id'];

    const CHANNEL_CASH = 'cash_pay'; //cash 现金；
    const CHANNEL_BALANCE = 'balance';  //balance 余额；
    const CHANNEL_ORDER = 'order'; //order 抵扣换货订单金额

    protected $appends = ['origin_type_text'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $prefix = config('ibrand.app.database.prefix', 'ibrand_');
        $this->setTable($prefix . 'o2o_refund_payment');
    }

    public function getOriginTypeTextAttribute()
    {
        switch ($this->origin_type) {
            case 'cash_pay':
                return '现金';
                break;
            case 'balance':
                return '余额';
                break;
            case 'order':
                return '换货金额抵扣';
                break;
            default:
                return '其他';
        }
    }
}